﻿using UnityEngine;
using System.Collections;

public class Axis : MonoBehaviour {

	public bool isGrounded;
    public Rigidbody2D target;
    public Animator anim;
    public Animator glass;
	
	void OnTriggerStay2D(Collider2D other)
	{
		if (other.tag == "Floor")
		{

            if (other.name == "MovablePlatform")
            {
                transform.parent = other.transform;
            }

			isGrounded = true;
            target.gravityScale = 1;
            anim.SetBool("Grounded", true);
			glass.SetBool("Grounded", true);
		}
        
	}
	void OnTriggerExit2D(Collider2D other)
	{
        transform.parent = null;
        
		if (other.tag == "Floor")
		{
            if (other.name == "MovablePlatform")
            {
                transform.parent = other.transform;
            }

			isGrounded = false;
            target.gravityScale = 4;
            anim.SetBool("Grounded", false);
			glass.SetBool("Grounded", false);
		}
        
	}

}
